from rest_framework import serializers
from . import models


class CouponModelSerializer(serializers.ModelSerializer):
    """
    优惠券序列化器
    """

    class Meta:
        model = models.Coupon
        fields = ('name', 'coupon_type', 'timer', 'condition', 'sale')


class UserCouponModelSerializer(serializers.ModelSerializer):
    """
    用户优惠券序列化器
    """
    coupon = CouponModelSerializer()

    class Meta:
        model = models.UserCoupon
        fields = ('id', 'start_time', 'coupon', 'end_time')
